<template>
	<view>
		<view class="bg">
		</view>
		<view class="top">
			<image src="../../static/image/bg.png" mode="" class="background"></image>
			<view class="information" v-if="!islogin">
				<view class="avatar">
					<image src="../../static/image/avatar1.png" mode=""></image>
				</view>
				<view class="oper">
					<view class="text">
						登录领福利，获得更多权限哦！
					</view>
					<view class="btn">
						<button @click="login">登陆</button>
					</view>
				</view>
			</view>
			<view class="person" v-else>
				<view class="avatar1">
					<image :src="userInfo.avatar" mode=""></image>
				</view>
				<view class="nickname">
					{{userInfo.nickname}}
				</view>
				<view class="code">
					ID编号：{{userInfo.code}}
				</view>
			</view>
		</view>
		<view class="middle">
			<view class="item" @click="toTransaction">
				<view class="image">
					<image src="../../static/image/record.png" mode=""></image>
				</view>
				<view class="text1">
					交易记录
				</view>
			</view>
			<view class="item" @click="tomyAddress">
				<view class="image">
					<image src="../../static/image/address.png" mode=""></image>
				</view>
				<view class="text1">
					收货地址
				</view>
			</view>
			<view class="item" @click="tofeedback">
				<view class="image">
					<image src="../../static/image/feedback.png" mode=""></image>
				</view>
				<view class="text1">
					意见反馈
				</view>
			</view>
			<view class="item" @click="toAboutUs">
				<view class="image">
					<image src="../../static/image/about.png" mode=""></image>
				</view>
				<view class="text1">
					关于我们
				</view>
			</view>
		</view>
		<view class="bottom_wrapper">
			<view class="bottom">
				<view class="title">
					<view class="myCash">
						我的钱包
						<view class="yellow">
						</view>
						<view class="shenglue" @click="toRechargeRecord">
							充值记录
						</view>
					</view>
					
				</view>
				<view class="cash" v-if="!islogin">
					<view class="cash_image">
						<image src="../../static/image/sad.png" mode=""></image>
					</view>
					<view class="text2">
						很抱歉！登录以后才可以查看哦！
					</view>
				</view>
				<view class="cash1" v-else>
					<view class="cash1_image">
						<image src="../../static/image/yue.png" mode=""></image>
						<view class="cash1_text">
							<view class="cash1_text1">
								账户余额
							</view>
							<view class="cash1_text2">
								￥{{userInfo.money}}
							</view>
						</view>
					</view>
					<view class="cash1_btn" @click="toRecharge">
						<button>充值</button>
					</view>
				</view>
			</view>
		</view>
		<!-- <button @click="clear">清楚登录态</button> -->
	</view>
</template>

<script>
	export default {
		data() {
			return {
				userInfo:{},
				islogin:uni.getStorageSync("token")
				// islogin:false
			}
		},
		
		async onShow() {
			this.userInfo=uni.getStorageSync("userInfo");
			let userInfo=await this.getUserInfo()
			this.userInfo=userInfo
			// let app=getApp()
			// this.islogin=app.globalData.islogi
			let {lden}=this.userInfo
			if(lden=="staff_cn"){
				uni.navigateTo({
					url:"/pages/inemployees/inforecast/inforecast"
				})
			}
			if(lden=="staff_db"){
				uni.navigateTo({
					url:"/pages/outemployees/roading/roading"
				})
			}
			this.islogin=uni.getStorageSync("token")
			
			
		},
		methods: {
			login(){
				uni.redirectTo({
					url:"/pages/login/login"
				})
			},
			async getUserInfo(){
				let token=uni.getStorageSync("token")
				const {data}=await this.$http({
					url:"member/info",
					header:{
						token
					}
				})
				return data.data
			},
			toTransaction(){
				let token=uni.getStorageSync("token");
				if(!token){
					uni.navigateTo({
						url:"/pages/login/login"
					})
					uni.showToast({
						title:"请先登陆",
						icon:"error"
					})
					return
				}
				uni.navigateTo({
					url:"/pages/mime/children/transaction/transaction"
				})
			},
			tomyAddress(){
				let token=uni.getStorageSync("token");
				if(!token){
					uni.navigateTo({
						url:"/pages/login/login"
					})
					uni.showToast({
						title:"请先登陆",
						icon:"error"
					})
					return
				}
				uni.navigateTo({
					url:"/pages/mime/children/myAddress/myAddress"
				})
			},
			tofeedback(){
				uni.navigateTo({
					url:"/pages/mime/children/feedback/feedback"
				})
			},
			toAboutUs(){
				uni.navigateTo({
					url:"/pages/mime/children/aboutus/aboutus"
				})
			},
			tomyWallet(){
				let token=uni.getStorageSync("token");
				if(!token){
					uni.navigateTo({
						url:"/pages/login/login"
					})
					uni.showToast({
						title:"请先登陆",
						icon:"error"
					})
					return
				}
				uni.navigateTo({
					url:"/pages/mime/children/myWallet/myWallet"
				})
			},
			toRecharge(){
				let token=uni.getStorageSync("token");
				if(!token){
					uni.navigateTo({
						url:"/pages/login/login"
					})
					uni.showToast({
						title:"请先登陆",
						icon:"error"
					})
					return
				}
				uni.navigateTo({
					url:"/pages/mime/children/recharge/recharge"
				})
			},
			toRechargeRecord(){
				let token=uni.getStorageSync("token");
				if(!token){
					uni.navigateTo({
						url:"/pages/login/login"
					})
					uni.showToast({
						title:"请先登陆",
						icon:"error"
					})
					return
				}
				uni.navigateTo({
					url:"/pages/mime/children/rechargeRecord/rechargeRecord"
				})
			}
			// clear(){
			// 	uni.clearStorage()
			// 	getApp().globalData.islogin=false
			// 	this.islogin=false
			// }
		}
	}
</script>

<style scoped>
.bg{
	position: fixed;
	left: 0;
	top: 0;
	width: 100%;
	height: 100%;
	background-color: #F1F1F1;
	z-index: -1;
}
.top .background{
	width: 755rpx;
	height: 300rpx;
}
.top{
	position: relative;
}
.information{
	position: absolute;
	left: 40rpx;
	top: 10%;
	display: flex;
	align-items: center;
}
.information .avatar image{
	width: 150rpx;
	height: 150rpx;
}
.information .oper{
	margin-left: 20rpx;
}
.information .oper .btn button{
	width: 160rpx;
	height: 70rpx;
	background: rgba(255,255,255,0.3);
	border-radius: 35rpx;
	font-size: 26rpx;
	font-family: PingFang SC;
	font-weight: 400;
	color: #FFFFFF;
}
.information .oper .btn{
	display: flex;
}
.text{
	font-size: 20rpx;
	font-family: PingFang SC;
	font-weight: 400;
	color: #FFFFFF;
	margin-bottom: 20rpx;
}
.register{
	margin-left: 20rpx;
}
.middle{
	padding: 0 40rpx;
	display: flex;
	justify-content: space-between;
}
.item{
	width: 20%;
	text-align: center;
}
.item .text1{
	margin-top: 8rpx;
	font-size: 26rpx;
	font-family: PingFang SC;
	font-weight: 400;
	color: #666666;
}
.item .image image{
	width: 80rpx;
	height: 80rpx;
}
.bottom_wrapper{
	padding: 40rpx;
}
.bottom{
	background: #FFFFFF;
	border-radius: 10rpx;
	box-sizing: border-box;
	padding-bottom: 60rpx;
}
.cash{
	margin-top: 10rpx;
	text-align: center;
}
.title{
	padding-left: 60rpx;
	padding-top:20rpx;
	font-size: 30rpx;
	font-family: PingFang SC;
	font-weight: 400;
	color: #333333;
}
.myCash{
	position: relative;
}
.title .yellow{
	position: absolute;
	left: -25rpx;
	top: 10rpx;
	width: 9rpx;
	height: 23rpx;
	background: #F7CC46;
	border-radius: 4rpx;
}
.cash .text2{
	margin-top: 10rpx;
	font-size: 26rpx;
	font-family: PingFang SC;
	font-weight: 400;
	color: #999999;
}
.cash_image image{
	width: 213rpx;
	height: 191rpx;
}

.cash1 .cash1_image image{
	width: 234rpx;
	height: 248rpx;
}
.cash1_image{
	position: relative;
	width: 234rpx;
	height: 248rpx;
	margin: 0 auto;
}
.cash1{
	text-align: center;
}
.cash1_text{
	position: absolute;
	left: 50%;
	top: 50%;
	transform: translate(-50%,-30%);
}
.cash1_text1{
	font-size: 36rpx;
	font-family: PingFang SC;
	font-weight: 600;
	color: #333333;
}
.cash1_text2{
	margin-top: 30rpx;
	font-size: 48rpx;
	font-family: PingFang SC;
	font-weight: 600;
	color: #F7CC46;
}
.cash1_btn{
	margin-top: 40rpx;
}
.cash1_btn button{
	width: 240rpx;
	height: 80rpx;
	background: #F7CC46;
	border-radius: 40rpx;
	font-size: 34rpx;
	font-family: PingFang SC;
	font-weight: 400;
	color: #FDFBFB;
}
.person{
	position: absolute;
	left: 50%;
	top: 5%;
	transform: translate(-50%);
	text-align: center;
}
.person .avatar1 image{
	width: 150rpx;
	height: 150rpx;
	border-radius: 50%;
}
.person .nickname{
	font-size: 32rpx;
	font-family: PingFang SC;
	font-weight: 600;
	color: #FFFFFF;
	margin-top: 5rpx;
}
.person .code{
	font-size: 26rpx;
	font-family: PingFang SC;
	font-weight: 400;
	color: #FFFFFF;
	margin-top: 5rpx;
}
.shenglue{
	font-size: 26rpx;
	font-family: PingFang SC;
	font-weight: 400;
	position: absolute;
	right: 5%;
	top: 4rpx;
}
/* .shenglue image{
	width: 33rpx;
	height: 8rpx;
} */
.btn{
	width: 150rpx;
}
</style>
